package logic

import (
	"context"

	"jinrigaoping/rpc/sys/internal/svc"
	"jinrigaoping/rpc/sys/sys"

	"github.com/zeromicro/go-zero/core/logx"
)

type SysUserInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSysUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SysUserInfoLogic {
	return &SysUserInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SysUserInfoLogic) SysUserInfo(in *sys.SysUserInfoReq) (*sys.SysUserInfoRes, error) {

	info, err := l.svcCtx.SysUserModel.FindOne(l.ctx, in.Id)
	if err != nil {
		logx.Errorf("SysUserInfo id: %d error: %v", in.Id, err)
		return nil, err
	}

	return &sys.SysUserInfoRes{
		Id:       info.Id,
		Account:  info.Account,
		Password: info.Password,
		Status:   info.Status,
		RoleId:   info.RoleId,
		Nickname: info.Nickname,
		Phone:    info.Phone,
		Email:    info.Email,
		Brief:    info.Brief,
	}, nil
}
